package org.giovanolli.mumi.controller.payment;

import org.giovanolli.mumi.controller.AbstractController;
import org.giovanolli.mumi.controller.AbstractModel;
import org.giovanolli.mumi.entities.PaymentConcept;
import org.giovanolli.mumi.entities.filter.PaymentConceptFilter;
import org.giovanolli.mumi.service.PaymentConceptService;
import org.giovanolli.mumi.service.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

@Controller("paymentConceptController")
public class PaymentConceptController extends AbstractController<PaymentConcept> {

	@Autowired
	private PaymentConceptService service;

	@Autowired
	private PaymentConceptModel model;

	@Override
	protected void bindEntityToModel() {
		PaymentConcept editedPaymentConcept = model.getEditedEntity();
		model.setName(editedPaymentConcept.getName());
		model.setDescription(editedPaymentConcept.getDescription());
		model.setPaymentConceptType(editedPaymentConcept.getPaymentConceptType());
	}

	@Override
	protected void bindModelToEntity() {
		PaymentConcept editedPaymentConcept = model.getEditedEntity();
		editedPaymentConcept.setName(model.getName());
		editedPaymentConcept.setDescription(model.getDescription());
		editedPaymentConcept.setPaymentConceptType(model.getPaymentConceptType());
	}

	protected Class<PaymentConcept> getEntityClass() {
		return PaymentConcept.class;
	}

	@Override
	protected AbstractModel<PaymentConcept> getModel() {
		return model;

	}

	@Override
	protected Service<PaymentConcept> getService() {
		return service;
	}

	public void init() {
		super.init();
		model.setFilter(new PaymentConceptFilter());
	}
}
